package com.hspedu.seckill.rabbitmq;

import com.hspedu.seckill.config.RabbitMQSecKillConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author: xujiabing
 * @date: 2024-12-18 20:58
 * @description: 秒杀商品-消息生产者
 */
@Service
@Slf4j
public class MQSenderMessage {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sendSeckillMessage(String message) {
        log.info("发送消息 = {}", message);

        rabbitTemplate.convertAndSend(
                RabbitMQSecKillConfig.EXCHANGE,
                "seckill.message",
                message
        );
    }
}
